[id].vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <!-- 页面头部 -->
  3. <HomePageHead></HomePageHead>
  4. <!-- 导航栏 -->
  5. <HomePageNavigation></HomePageNavigation>
  6. <!-- 列表页广告一 -->
  7. <HomeTopTen :imgurl="adImg1" v-if="adImg1"></HomeTopTen>
  8. <!-- 资讯列表 -->
  9. <div class="newsDetail">
  10. <div class="inner">
  11. <div class="innerLeft">
  12. <!-- 面包屑导航 -->
  13. <div class="breadcrumb phone_none">
  14. <div class="inner">
  15. <span class="location"> 当前位置:</span>
  16. <el-breadcrumb :separator-icon="ArrowRight">
  17. <el-breadcrumb-item>
  18. <NuxtLink to="/">首页</NuxtLink>
  19. </el-breadcrumb-item>
  20. <el-breadcrumb-item v-if="parent_name != ''">
  21. <NuxtLink :to="`/${parent_pinyin}/index.html`"> {{ parent_name }}</NuxtLink>
  22. </el-breadcrumb-item>
  23. <!-- <el-breadcrumb-item>
  24. <NuxtLink :to="`list-1.html`"> {{ routLevelTitle }}</NuxtLink>
  25. </el-breadcrumb-item> -->
  26. <el-breadcrumb-item>{{ routeNewsTtitle }}</el-breadcrumb-item>
  27. </el-breadcrumb>
  28. </div>
  29. </div>
  30. <div class="breadcrumb_box pc_none">
  31. <span class=" ">当前位置:</span>
  32. <NuxtLink to="/">首页</NuxtLink>
  33. <span class=" ">&gt;</span>
  34. <NuxtLink :to="`/${parent_pinyin}/index.html`" v-if="parent_name != ''"> {{ parent_name }}</NuxtLink>
  35. <span class=" " v-if="parent_name != ''">&gt;</span>
  36. {{ routeNewsTtitle }}
  37. </div>
  38. <div class="LeftTop">
  39. <h1>{{ newsDetail.title }}</h1>
  40. <p class="phone_none">
  41. 来源: <span>{{ newsDetail.copyfrom }}</span>
  42. 作者: <span>{{ newsDetail.author }}</span>
  43. 发布时间: <span>{{ time }}</span>
  44. </p>
  45. <p class="pc_none">
  46. <span>{{ newsDetail.copyfrom }}</span>
  47. <span>{{ newsDetail.author }}</span>
  48. <span>{{ time }}</span>
  49. </p>
  50. </div>
  51. <div class="leftBottom" v-html="newsDetail.content" v-if="newsDetail.content" @click="openPreview">
  52. </div>
  53. <div v-if="previewVisible" class="preview-modal" @click="closePreview">
  54. <img :src="selectedImage" alt="Preview">
  55. </div>
  56. <!-- 免责声明: -->
  57. <div class="disclaimer" v-if="newsDetail.copyfrom != '本网'">
  58. <p>原文链接:{{ newsDetail.fromurl }}</p>
  59. <p>[免责声明]本文来源于网络转载,仅供学习交流使用,不构成商业目的。 版权归原作者所有,如涉及作品内容,版权和其他问题,请在30日与本网联系,我们将第一时间处理。</p>
  60. </div>
  61. <div v-if="articleChoice">
  62. <HomeSurveyvote></HomeSurveyvote>
  63. </div>
  64. <!-- 推荐阅读 -->
  65. <div class="recommendRead" v-if="newsDetail.commendArticle != false">
  66. <div class="recommendReadTitle phone_none">
  67. 推荐阅读
  68. </div>
  69. <div class="recommend_read_head_box pc_none">
  70. <span class="recommend_read_head">
  71. 推荐阅读
  72. </span>
  73. </div>
  74. <div class="recommendReadList">
  75. <div class="recommendReadListTitle" v-for="(item, index) in newsDetail.commendArticle"
  76. :key="item.id">
  77. <a :href="`/${item.alias_pinyin}/${item.id}.html`" v-if="index < 3">
  78. {{ item.title }}
  79. </a>
  80. <span v-if="index < 3">{{ getTime(item.created_at, "month", 1) }}</span>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. <div class="innerRight">
  86. <!-- 热点资讯1 -->
  87. <div class="hotList1">
  88. <DetailHotNews></DetailHotNews>
  89. </div>
  90. <!-- 热点资讯2 -->
  91. <div class="hotList2">
  92. <DetailHotNews2></DetailHotNews2>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <!-- 页面底部 -->
  98. <HomeFoot1></HomeFoot1>
  99. </template>
  100. <script setup>
  101. //1.页面依赖 start ---------------------------------------->
  102. import { onMounted } from 'vue'
  103. import { ElBreadcrumb, ElBreadcrumbItem } from 'element-plus'
  104. import { ArrowRight } from '@element-plus/icons-vue'
  105. //1.页面依赖 end ---------------------------------------->
  106. //2.页面路径 start ---------------------------------------->
  107. const targetSegment = getRoutePath(1);
  108. let routeId;
  109. //通过导航路径反向查询导航id
  110. const getRouteId = await requestDataPromise('/web/getWebsiteRoute', {
  111. method: 'GET',
  112. query: {
  113. 'pinyin': targetSegment,
  114. },
  115. });
  116. if (getRouteId.code == 200) {
  117. routeId = getRouteId.data.category_id
  118. } else {
  119. console.log("错误位置:获得页面路径")
  120. }
  121. //2.页面路径 start ---------------------------------------->
  122. //3.面包屑 start ---------------------------------------->
  123. const route = useRoute();
  124. const articleId = parseInt(route.params.id); //获得该页面的id
  125. //3.1 获得父级栏目的名称、id
  126. const parent_name = ref([]);
  127. const parent_id = ref([]);
  128. const parent_pinyin = ref("");
  129. const parent_children_count = ref(0)
  130. let getParentNav = async () => {
  131. const listData = await requestDataPromise('/web/getOneWebsiteCategory', {
  132. method: 'GET',
  133. query: {
  134. 'catid': routeId
  135. },
  136. });
  137. if (listData.code == 200) {
  138. parent_name.value = listData.data.alias;
  139. parent_id.value = listData.data.parent_id;
  140. parent_pinyin.value = listData.data.aLIas_pinyin;
  141. parent_children_count.value = listData.data.children_count;
  142. } else {
  143. console.log("错误位置:获取面包屑导航")
  144. }
  145. }
  146. getParentNav();
  147. //3.页面依赖 end ---------------------------------------->
  148. //4.页面数据 start ---------------------------------------->
  149. //4.1 资讯详情
  150. const newsDetail = ref({})
  151. const routeNewsTtitle = ref("");
  152. //4.2 发布日期
  153. const time = ref("");
  154. //4.3 路径
  155. const routLevelTitle = ref("");
  156. const routLevelId = ref("");
  157. //4.4 是否展示投票
  158. const articleChoice = ref(false);
  159. //4.5 获取详情
  160. async function getPageData() {
  161. const mkdata = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  162. method: 'GET',
  163. query: {
  164. 'articleid': articleId
  165. },
  166. });
  167. if (mkdata.code == 200) {
  168. //判断是否显示投票
  169. if (mkdata.data.is_survey == 1) {
  170. console.log("本篇文章含有投票!")
  171. articleChoice.value = true;
  172. }
  173. //获取内容
  174. newsDetail.value = mkdata.data;
  175. //获取路径
  176. routLevelTitle.value = newsDetail.value.cat_name;
  177. routLevelId.value = newsDetail.value.category_id;
  178. //获取发布时间
  179. time.value = newsDetail.value.updated_at.split(' ')[0];
  180. //修正标题长度
  181. if (newsDetail.value.title.length >= 20) {
  182. routeNewsTtitle.value = newsDetail.value.title.substr(0, 20) + "...";
  183. } else {
  184. routeNewsTtitle.value = newsDetail.value.title
  185. }
  186. } else {
  187. console.log("错误位置:获取详情内容")
  188. }
  189. }
  190. getPageData();
  191. //4.页面数据 end ---------------------------------------->
  192. //5.广告 start ---------------------------------------->
  193. let adImg1 = ref([]);
  194. onMounted(async () => {
  195. const { $webUrl, $CwebUrl } = useNuxtApp();
  196. //广告1
  197. let url = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snscw_detail_0001`
  198. const responseAd1 = await fetch(url, {
  199. headers: {
  200. 'Content-Type': 'application/json',
  201. 'Userurl': $CwebUrl,
  202. 'Origin': $CwebUrl
  203. }
  204. });
  205. const resultAd1 = await responseAd1.json();
  206. adImg1.value = resultAd1.data[0];
  207. //广告2
  208. let url2 = `${$webUrl}/web/getWebsiteAdvertisement?ad_tag=snscw_detail_0002`
  209. const responseAd2 = await fetch(url2, {
  210. headers: {
  211. 'Content-Type': 'application/json',
  212. 'Userurl': $CwebUrl,
  213. 'Origin': $CwebUrl
  214. }
  215. });
  216. const resultAd2 = await responseAd2.json();
  217. adImg2.value = resultAd2.data[0];
  218. })
  219. //5.广告 end ---------------------------------------->
  220. //6.设置seo信息 start---------------------------------------->
  221. const setData = await requestDataPromise('/web/selectWebsiteArticleInfo', {
  222. method: 'GET',
  223. query: {
  224. 'articleid': articleId
  225. },
  226. });
  227. if (setData.code == 200) {
  228. let seoTitle = setData.data.title;
  229. let seoDescription = setData.data.introduce;
  230. let seoKeywords = setData.data.keyword;
  231. let seoSuffix = setData.data.suffix;
  232. let seoName = setData.data.website_name;
  233. useSeoMeta({
  234. title: seoTitle + "_" + seoName + "_" + seoSuffix,
  235. meta: [
  236. { name: 'description', content: seoDescription + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  237. { name: 'keywords', content: seoKeywords + "_" + seoName + "_" + seoSuffix, tagPriority: 10 },
  238. { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no',tagPriority: 10 }
  239. ]
  240. });
  241. } else {
  242. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  243. // console.log("错误位置:设置详情页面SEO数据")
  244. // console.log("后端错误反馈:", setData.message)
  245. // console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
  246. }
  247. //6.设置seo信息 end---------------------------------------->
  248. //8.页面图片放大 start---------------------------------------->
  249. const previewVisible = ref(false)
  250. const selectedImage = ref(' ')
  251. const openPreview = (event) => {
  252. if (event.target.tagName === 'IMG') {
  253. selectedImage.value = event.target.src;
  254. previewVisible.value = true;
  255. }
  256. }
  257. const closePreview = () => {
  258. previewVisible.value = false;
  259. }
  260. //8.页面图片放大 end---------------------------------------->
  261. </script>
  262. <style lang="less" scoped>
  263. @import url('@/assets/css/detail.less');
  264. </style>
  265. <style lang="less" scoped>
  266. @media screen and (min-width:801px){/*pc*/
  267. .pc_none{display:none;}
  268. }
  269. @media screen and (max-width:800px){/*ipad_phone*/
  270. .breadcrumb_box{
  271. height:22px;width:100%;margin:15px auto 0px;
  272. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  273. font-size:14px;
  274. color:#666;
  275. *{
  276. font-size:14px;
  277. display:inline ;
  278. color:#666;
  279. line-height:22px;height:22px;
  280. margin-right:5px;
  281. }
  282. }
  283. .newsDetail .inner{width:92%;}
  284. .newsDetail .inner .innerLeft{width:100%;float:none;margin:0px auto;}
  285. .newsDetail .inner .innerLeft .LeftTop > h1{font-size:20px;line-height:28px;margin-bottom:15px;}
  286. .newsDetail .inner .innerLeft .leftBottom{width:100%;margin-bottom:14px;}
  287. .newsDetail .inner .innerLeft .leftBottom *,.newsDetail .inner .innerLeft .leftBottom{line-height:24px!important;font-size:16px;background:rgba(0,0,0,0);}
  288. .newsDetail .inner .innerLeft .leftBottom /deep/img{display:block;width:100%;height:auto;}
  289. .newsDetail .inner .innerLeft .disclaimer{width:100%;}
  290. .newsDetail .inner .innerLeft .disclaimer *{
  291. word-wrap: break-word;width:100%!important;display:block!important;
  292. overflow-wrap: break-word;font-size:16px;
  293. white-space: pre-wrap;
  294. word-break: break-all;
  295. }
  296. .newsDetail{margin-bottom:10px;}
  297. .newsDetail .inner .innerLeft .LeftTop{border-top:solid 1px #255590;margin-top:10px;padding-top:15px;}
  298. // 推荐阅读
  299. .index_3_box_vote{overflow:hidden;margin-top:39px;}
  300. .index_3_box_vote .inquire{margin-top:15px;height:auto;}
  301. .index_3_box_vote .inquire p{height:auto;padding:0;font-size:14px;
  302. margin:0px 0px 5px 18px;}
  303. .index_3_box_vote .inquire .radio .el-radio.el-radio--large .el-radio__label span{font-size:14px;}
  304. .index_3_box_vote .voteTitle{font-size:14px;}
  305. .index_3_box_vote .inquire .btn{padding-left:22px;}
  306. .index_3_box_vote .inquire .radio .el-radio.el-radio--large{margin-bottom:3px;}
  307. .index_3_box_vote .inquire .radioBox{height:auto;
  308. padding:0px 0px 12px 18px;}
  309. .index_3_box_vote .inquire .radio .el-radio-group{width:100%;}
  310. .index_3_box_vote .inquire .btn button{width:auto;padding:0px 10px;line-height:33px;height:33px;font-size:14px;margin-bottom:14px;}
  311. .newsDetail .inner .innerLeft .recommendRead{width:100%; margin:25px auto 32px;border:none;}
  312. .newsDetail .inner .innerLeft .recommendRead .recommendReadTitle{width:100%;margin:22px 0px;}
  313. .recommend_read_head_box{overflow:hidden;border-bottom:1px solid #D9D9D9;}
  314. .recommend_read_head{
  315. width:auto;font-size:14px;box-sizing:border-box;height:33px;line-height:33px;
  316. color: #255590;
  317. border-bottom:1px solid #255590;float:left;
  318. }
  319. .newsDetail .inner .innerLeft .recommendRead .recommendReadList{
  320. height:auto;margin-top:11px; min-height:auto;padding-bottom:8px;
  321. }
  322. .newsDetail .inner .innerLeft .recommendRead .recommendReadList .recommendReadListTitle{
  323. margin-top:0px;overflow:hidden;width:100%;
  324. }
  325. .newsDetail .inner .innerLeft .recommendRead .recommendReadList .recommendReadListTitle a{
  326. line-height:33px;height:33px;font-size:14px;float:left;max-width:90%;
  327. word-break: keep-all; white-space: nowrap;overflow:hidden;text-overflow:ellipsis;
  328. }
  329. .newsDetail .inner .innerLeft .recommendRead .recommendReadList .recommendReadListTitle span{display:none;}
  330. .newsDetail .inner .innerRight{display:none;}
  331. .phone_none{display:none;}
  332. }
  333. </style>